home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / WIN / VB_CTRLS / MHSAMPL.ZIP / MHSAMPLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-14  |  11.9 KB  |  325 lines

  1. //---------------------------------------------------------------------------
  2. // MhSample.h
  3. //
  4. //  The header file contains initialization information that VB uses to know
  5. //  all about your custom control.  This includes properties, events, default
  6. //  values, etc.  You can also define any global variables, macros, etc.
  7. //---------------------------------------------------------------------------
  8.  
  9. // Bitmap ID's - Define ID's for use in the resource file and .C file
  10. //               VB Uses the bitmap id's to load the toolbox bitmaps.
  11. //               Note the 0, 1, 3, and 6 have significant meanings.  
  12. //               VB Uses the base number + x (1, 3, or 6) to get the 
  13. //               bitmaps for the correct type of display that VB 
  14. //               is running on.
  15.  
  16.      #define IDBMP_SAMPLEU             8000    // VGA Button Up bitmap
  17.      #define IDBMP_SAMPLED             8001    // VGA Button Down bitmap
  18.      #define IDBMP_SAMPLEMU            8003    // Monochrome Bitmap
  19.      #define IDBMP_SAMPLEEU            8006    // EGA Bitmap
  20.  
  21. //If the resource compile is invoked do not do any of this other stuff.
  22. //Only the bitmaps id's are used in the .RC file.
  23.  
  24. #ifndef RC_INVOKED
  25.  
  26. //---------------------------------------------------------------------------
  27. // MhSample Programmer Defined Structure (Instance Specific Data)
  28. //---------------------------------------------------------------------------
  29. typedef struct tagMHSAMPLE
  30. {
  31.     //Programmer defined data
  32.     SHORT junk;
  33.     SHORT Flags;
  34.     HFONT hfont;
  35.     SHORT DefaultProperty;
  36. } MHSAMPLE;
  37.  
  38. //Create Pointer Type
  39. typedef MHSAMPLE FAR * PMHSAMPLE;
  40.  
  41. //Dereference Macro - Dereferences the handle returned by VB into a pointer
  42. //to the instance specific programmer defined structure
  43.  
  44. #define MHSAMPLEDEREF( hctl )   CONTROLDEREF( MHSAMPLE, hctl )
  45.  
  46. // Error Message Code Constants
  47. #define EBER_NONE 0
  48. #define ERR_OUTOFMEMORY 1
  49. #define ERR_BADPROPERTY 380
  50.  
  51.  
  52. //---------------------------------------------------------------------------
  53. // Prototype of the Control message handling Procedure
  54. //---------------------------------------------------------------------------
  55. LONG _export MhSampleCtlProc( HCTL, HWND, USHORT, USHORT, LONG );
  56.  
  57.  
  58. //--------------------------------------------------------------------------
  59. //User Defined function prototypes
  60. //--------------------------------------------------------------------------
  61. VOID NEAR MhSamplePaintControl(HCTL, HWND, HDC);
  62.  
  63. //---------------------------------------------------------------------------
  64. // Programmer defined Property Structures and information
  65. //---------------------------------------------------------------------------
  66.  
  67. //Sample list used in enumerated properties
  68. CHAR szSampleAction[]= "0 - None\0"\
  69.                      "1 - Do Something\0"\
  70.                      "2 - Do Something Else\0"\
  71.                      "3 - Another Thing\0"\
  72.                      "4 - And Another\0"\
  73.                      "5 - One More\0"\
  74.                      "6 - Last Thing\0"\
  75.                      "\0";
  76.  
  77. PROPINFO propinfoSampleAction =
  78. {
  79.      "Action",                  // Property Name
  80.      DT_ENUM | PF_fGetMsg | 
  81.      PF_fSetMsg | PF_fNoShow,   // Flags
  82.      0,                         // Offset into PDS (PF_fGetData/SetData)
  83.      0,                         // Bit packing Mask for DT_BOOL, SHORT, & ENUM
  84.      0,                         // Default Value for this property (PF_fDefVal)
  85.      szSampleAction,             // String Array for valid values (DT_ENUM)
  86.      6                          // Highest Value allowed for DT_ENUM, 0=Don't Validate
  87. }; 
  88.  
  89. /*   Sample Properties (1 of each type)
  90.  
  91. PROPINFO propinfoSampleHelpCommand =
  92. {
  93.      "HelpCommand",
  94.      DT_SHORT | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  95.      OFFSETIN(MHSAMPLE, HelpCommand), 0, 0
  96.  
  97. };
  98.  
  99. PROPINFO propinfoSampleHelpContext =
  100. {
  101.      "HelpContext",
  102.      DT_LONG | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  103.      OFFSETIN(MHSAMPLE, HelpContext), 0, 0
  104.  
  105. };
  106.  
  107. PROPINFO propinfoSampleHelpFile =
  108. {
  109.      "HelpFile",
  110.      DT_HSZ | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  111.      OFFSETIN(MHSAMPLE, hszHelpFile), 0, 0
  112.  
  113. };
  114.  
  115. PROPINFO propinfoSamplePicture =
  116. {
  117.      "Picture",
  118.      DT_PICTURE | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  119.      OFFSETIN(MHSAMPLE, hpicPicture), 0, 0
  120.  
  121. };
  122.  
  123. PROPINFO propinfoSamplePicture =
  124. {
  125.      "Picture",
  126.      DT_PICTURE | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  127.      OFFSETIN(MHSAMPLE, hpicPicture), 0, 0
  128.  
  129. };
  130.  
  131. PROPINFO propinfoSampleColor =
  132. {
  133.      "Color",
  134.      DT_COLOR | PF_fGetData | PF_fSetData | PF_fSaveData | PF_fDefVal,
  135.      OFFSETIN(MHSAMPLE, Color), 0, 0
  136.  
  137. };
  138.  
  139.         
  140.         ========================  Property Flags =================================
  141.         
  142.         DT_BOOL       = (1 bit packed or BOOL) Bool property (True/False)
  143.         DT_COLOR      = (LONG) VB Color value
  144.         DT_ENUM       = (Bitpacked or SHORT) Value 0 - 255 max
  145.         DT_HLSTR      = (HLSTR) Basic String handle (2.0+)
  146.         DT_HSZ        = (HSZ) Handle for a Null Terminated Basic String
  147.         DT_LONG       = (LONG) Long Integer
  148.         DT_PICTURE    = (HPIC) Handle to a VB Picture
  149.         DT_REAL       = (FLOAT) Floating point number
  150.         DT_SHORT      = (SHORT) Short Integer
  151.         DT_XPOS       = (LONG) X Coordinate in TWIPS
  152.         DT_XSIZE      = (LONG) X Size in TWIPS
  153.         DT_YPOS       = (LONG) Y Coordinate in TWIPS
  154.         DT_YSIZE      = (LONG) Y Size in TWIPS
  155.         
  156.         PF_fDefVal    = if prop = Default Value then don't load/save from Formfile
  157.                                         Use default value field of property structure.
  158.         PF_fEditable  = Allows direct editing in the settings box
  159.         PF_fGetData   = VB Gets Property value by directly accessing PDS
  160.         PF_fGetHszMsg = When value is to be displayed in property window VB will
  161.                                         send a VBM_GETPROPERTYHSZ message to the control.
  162.         PF_fGetMsg    = VB sends a VBM_GETPROPERTY message to control to get the
  163.                                         value of a property
  164.         PF_fNoMultiSelect = Keeps a control from being allowed to be selected as
  165.                                                 a group when user is using the "multiple" selection
  166.                                                 in VB 2.0 +
  167.         PF_fNoInitDef = Prevents VB from setting the property to the default value
  168.                                         during loading of the control.
  169.         PF_fNoRuntimeR = Indicates that a property is ReadOnly at run-time (2.0+)
  170.         PF_fNoRuntimeW = Indicates that a property is WriteOnly at run-time
  171.         PF_fNoShow     = Don't show property in property window at design-time
  172.         PF_fPreHwnd    = Causes the property to be loaded before the window (HWND)
  173.                                          is created.
  174.         PF_fPropArray  = Specifies that the property is an Array (must use PF_NoShow
  175.                                          as arrays are not allowed at design time)
  176.         PF_fSaveData   = VB will save/load property from Form File
  177.         PF_fSaveMsg    = Causes VB to send a VBM_SAVEPROPERTY message so we can save
  178.                                          to the Form File
  179.         PF_fSetCheck   = VB will send a VBM_CHECKPROPERTY message to control when
  180.                                          user sets property at design or run-time.
  181.         PF_fSetData    = VB sets data directly in PDS
  182.         PF_fUpdateOnEdit = VB updates display as each character is typed during edit
  183.  
  184.  
  185. */
  186.  
  187.  
  188. //---------------------------------------------------------------------------
  189. // Custom Programmer defined Event procedure parameters and prototypes
  190. //---------------------------------------------------------------------------
  191.  
  192. //Parameters for an event passing 2 integers
  193.  
  194. // Parm Types:
  195. // ET_I2 = 16 bit Integer, ET_I4 = 32 bit Integer
  196. // ET_R4 = 4 byte Real   , ET_R8 = 8 byte Real
  197. // ET_CY = Currency      , ET_FS = Fixed length String
  198. // ET_HLSTR = HLSTR
  199.  
  200. WORD ParmsI2xI2[] = { ET_I2, ET_I2 };
  201.  
  202. EVENTINFO eventinfoSampleClosed =
  203.      {
  204.             "SampleClosed",         // VB Custom Event Name
  205.             2,                     // Number of arguments - not including Index
  206.             4,                     // Number of WORDS represented by arg list
  207.             ParmsI2xI2,            // Pointer to byte array describing parameters
  208.             "Hwnd as Integer, WhichDialog as Integer"  // Event Text Parameter names
  209.      };
  210.  
  211. /*   Sample Event with no parameters
  212.      EVENTINFO eventinfoFilenameChange =
  213.      {
  214.             "FilenameChange",
  215.             0,
  216.             0,
  217.             NULL,
  218.             NULL
  219.      };
  220. */
  221. //---------------------------------------------------------------------------
  222. // Event list
  223. //---------------------------------------------------------------------------
  224. // Define the consecutive indicies for the events
  225. // We refer to events by number - always add new events to bottom of list
  226. //---------------------------------------------------------------------------
  227. #define EVENT_SAMPLE_SAMPLECLOSED    0x0000
  228.  
  229. //---------------------------------------------------------------------------
  230. // Property list
  231. //---------------------------------------------------------------------------
  232. // Define the consecutive indicies for the properties
  233. // We refer to properties by number - always add new props to bottom of list
  234. // We define these macros to make the code much easier to read
  235. //---------------------------------------------------------------------------
  236.  
  237. #define IPROP_SAMPLE_CTLNAME         0x0000
  238. #define IPROP_SAMPLE_INDEX           0x0001
  239. #define IPROP_SAMPLE_PARENT          0x0002
  240. #define IPROP_SAMPLE_LEFT            0x0003
  241. #define IPROP_SAMPLE_TOP             0x0004
  242. #define IPROP_SAMPLE_WIDTH           0x0005
  243. #define IPROP_SAMPLE_HEIGHT          0x0006
  244. #define IPROP_SAMPLE_TAG             0x0007
  245. #define IPROP_SAMPLE_HWND            0x0008
  246. #define IPROP_SAMPLE_ACTION          0x0009
  247. #define IPROP_SAMPLE_BACKCOLOR       0x000A
  248. #define IPROP_SAMPLE_FONTNAME        0x000B
  249.  
  250.  
  251. // Property List - VB uses this to know what properties your control will 
  252. //                 have.  Add new properties to end of list.  Make sure you
  253. //                 add a property index # above to match each property.
  254.  
  255. PPROPINFO proplistSample[] =
  256. {
  257.      PPROPINFO_STD_CTLNAME,
  258.      PPROPINFO_STD_INDEX,
  259.      PPROPINFO_STD_PARENT,
  260.      PPROPINFO_STD_LEFT,
  261.      PPROPINFO_STD_TOP,
  262.      PPROPINFO_STD_WIDTH,
  263.      PPROPINFO_STD_HEIGHT,
  264.      PPROPINFO_STD_TAG,
  265.      PPROPINFO_STD_HWND,
  266.      &propinfoSampleAction,
  267.      PPROPINFO_STD_BACKCOLOR,
  268.      PPROPINFO_STD_FONTNAME,
  269.     NULL  
  270. };
  271.  
  272. // Event List - VB uses this to know what events your control will 
  273. //              have.  Add new Events to end of list.  Make sure you
  274. //              add an event index # above to match each property.
  275.  
  276. PEVENTINFO eventlistSample[] =
  277. {
  278.      &eventinfoSampleClosed,
  279.      NULL
  280. };  
  281.  
  282. //Model information - This model is registered with a call to 
  283. //                    VBRegisterControl.  The model contains
  284. //                    all information that VB needs to create 
  285. //                    instances of the control onto a form.
  286.  
  287. MODEL modelMhSample =
  288. {
  289.      VB_VERSION,                          // VB version being used
  290.      MODEL_fLoadMsg | MODEL_fDesInteract, // MODEL flags
  291.      (PCTLPROC)MhSampleCtlProc,            // Control procedure
  292.      CS_DBLCLKS | CS_HREDRAW | 
  293.                 CS_VREDRAW,                     // Class style
  294.      WS_CHILD,                            // default Window style
  295.      sizeof(MHSAMPLE),                     // size of Programmer Defined Struct MHSAMPLE 
  296.      IDBMP_SAMPLEU,                        // First Palette bitmap ID#
  297.      "MhSample",                           // VB Default Control name
  298.      "MhSample",                           // Visual Basic class name (IF...TYPEOF)
  299.      NULL,                                // Parent class name (for subclassing)
  300.      proplistSample,                       // Properties list
  301.      eventlistSample,                      // Events list
  302.      IPROP_SAMPLE_ACTION,                  // Default Property in property viewer
  303.      EVENT_SAMPLE_SAMPLECLOSED              // Default Event shown in code window
  304. };
  305.  
  306. // Items below are used to point to the controls model.  The standard
  307. // way of accessing the model information (if necessary) of a custom control
  308. // is to call the function VBGetModelInfo which is exported by each custom
  309. // control (VB 2.0+).  Once you have a pointer to the modelinfo you can 
  310. // extract information about properties, events, etc.
  311.  
  312. LPMODEL modellistMhSample[] =
  313. {
  314.      &modelMhSample,           
  315.      NULL
  316. };
  317.  
  318. MODELINFO modelinfoMhSample =
  319. {
  320.      VB_VERSION,             // VB version being used
  321.      modellistMhSample        // MODEL list
  322. };
  323.  
  324. #endif  // RC_INVOKED
  325.